package com.twu.biblioteca;

import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class UserQueryHandler {
    private Scanner scanner;
    private PrintStream ps;

    UserQueryHandler(PrintStream ps){
        this(ps, System.in);
    }

    UserQueryHandler(PrintStream ps, InputStream is){
        this.scanner = new Scanner(is);
        this.ps = ps;
    }

    public String userForString(String queryText){
        ps.println(queryText);
        return scanner.nextLine();
    }

    public int userForInt(String queryText){
        ps.println(queryText);
        return Integer.parseInt(scanner.nextLine());
    }
}
